export default {
    data() {
        return {
            rulelist: {
                input: [{ required: true, message: '请输入', trigger: 'blur' }],
                sort: [{ required: false, message: '请输入正整数', pattern: /^[+]{0,1}(\d+)$/, trigger: 'blur' }],
                select: [{ required: true, message: '请选择', trigger: 'change' }]
            }, // 模态框验证规则
            power1: false,
            power2: false,
            power3: false,
            power4: false,
            power5: false
        }
    },
    methods: {
        poweredit (list) {
            this.state = JSON.parse(localStorage.getItem('poweredit'));
            for (let item of this.state) {
                for (let it of list) {
                   if (item.name === it.name) {
                       this[`power${it.key}`] = item.bool
                   }
                }
            }
        },
        getrule (data) {
            /*复制下面的在在initial函数中，required可不填，默认true，sort默认false*/
            /*let data = [
                    {name:'input',key:'sort', required: false},
                    {name:'sort',key:'sort', required: true}
                ]
              this.relus = this.getrule(data)
             */
            let list = {}
            data.forEach(item => {
                list[item.name] = JSON.parse(JSON.stringify(this.rulelist[item.key]))
                if (item.required === true||item.required === false){
                    list[item.name][0].required = item.required
                }
            });
            return list
        }
    }
}